<template lang="html">
  <div class="user_page user_page_three">
    <div class="user_page_three_top">
      <div class="user_page_three_top_content">
        <div class="shopping_rights_bg" @click="goToRights"></div>
        <div class="open_vip_btn" @click="goToOpenVip"></div>
      </div>
    </div>
    <div class="user_page_three_prd">
      <div class="user_page_three_prd_top">
        <div class="user_page_three_prd_top_content" @click="continueBuy()">
          <div class="left">
            <img :src="special_push_prd.product_image" alt="">
          </div>
          <div class="product_right">
            <p class="product_name">{{special_push_prd.product_short_name}}</p>
            <div class="product_details">
              <p class="product_details_content">{{special_push_prd.product_tips}}</p>
              <p>¥{{special_push_prd.product_unit_price}}</p>
            </div>
            <div class="product_bottom">
              <p>{{special_push_prd.rights_title}}</p>
            </div>
          </div>
        </div>
        <div class="tetui"></div>
      </div>
      <div class="user_page_three_prd_bottom">
        <div class="user_page_three_prd_content">
          <template v-for="(item, index) in prd_list">
            <div class="user_product_card" :key="index">
              <div class="user_product_img" @click="continueBuyList(item)">
                <img :src="item.product_image" alt="">
                <p>{{item.rights_title}}</p>
              </div>
              <p class="user_product_name">{{item.product_short_name}}</p>
              <p class="user_product_details">{{item.product_tips}}</p>
              <h3 class="user_product_price">¥ {{item.product_unit_price}}</h3>
              <div class="hots_tips" v-if="item.is_boom === 1"></div>
            </div>
          </template>
          <div class="user_product_card" @click="goMorePrd">
            <div class="user_product_img more_prd">
              <img src="../../../assets/image/member/user_page_three/more_prd.png" alt="">
              <div class="more_prd_btn">
                <span>查看更多</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="user_page_three_12_rights">
      <div class="user_page_three_rights_content">
        <div class="prd_1">
          <div class="getShoppingGoods" @click="goToEquity(0)"></div>
          <div class="getShare" @click="goToEquity(1)"></div>
        </div>
        <div class="coupon_rights">
          <div class="coupon_content">
            <img src="../../../assets/image/member/user_page_three/coupon_1100.png" alt="">
            <img src="../../../assets/image/member/user_page_three/coupon_900.png" alt="">
            <img src="../../../assets/image/member/user_page_three/coupon_600.png" alt="">
            <img src="../../../assets/image/member/user_page_three/coupon_400.png" alt="">
          </div>
          <div class="getCoupon" @click="goToEquity(2)"></div>
        </div>
        <div class="prd_2">
          <div class="getDiscount" @click="goToEquity(3)"></div>
          <div class="getIntegral" @click="goToEquity(4)"></div>
        </div>
        <div class="prd_3">
          <div class="getDiscount" @click="goToEquity(5)"></div>
          <div class="getIntegral" @click="goToEquity(6)"></div>
        </div>
        <div class="prd_4">
          <div class="getSeckill" @click="goToEquity(7)"></div>
        </div>
        <div class="right_1" @click="goToEquity(8)">
          <div class="getFamily"></div>
        </div>
        <div class="right_2" @click="goToEquity(9)">
          <div class="getTrain"></div>
        </div>
        <div class="right_3" @click="goToEquity(10)">
          <div class="getTutor"></div>
        </div>
        <div class="right_4" @click="goToEquity(11)">
          <div class="getDeliverGoods"></div>
        </div>
        <div class="right_more">
          <p>+更多权益陆续叠加中</p>
        </div>
      </div>
    </div>
    <div class="user_page_three_bottom" @click="goToRights">
      立即参加
    </div>
  </div>
</template>

<script>
import Tool from '@/utils/tool.js'
import Domain from '@/utils/domain.js'

export default {
  props: ['page_type', 'invite_info', 'user_info'],
  // components: { Swipe, PrdItem },
  data () {
    return {
      active: 1,
      first_show: false,
      last_show: false,
      prd_list: [],
      special_push_prd: {},
      active_prd: '',
      parent_info: []
    }
  },
  created () {
    this.getPrdList()
  },
  methods: {
    share () {
      var url = encodeURIComponent('pages/activity/join_vip/join_vip?invite=' + this.user_info.invite_id)
      var title = encodeURIComponent('倾情推荐！开启超级会员之旅，超值特权嗨不停。')
      var desc = encodeURIComponent('Hi，我是' + this.user_info.user_nickname + '分享一个正品购物平台给你')
      var imgurl = encodeURIComponent(Domain('/wechat/images/v4/share_vip.png'))
      let isClient = Tool.isClient()
      if (isClient) {
        window.location = 'yggshare://title=' + title + '&desc=' + desc + '&imgurl=' + imgurl + '&url=' + url
      } else {
        this.$toast('h5分享微信')
      }
    },
    getPrdList () {
      return new Promise((resolve, reject) => {
        this.$Axios({ url: 'product', params: { is_gift_bag: 1, pagesize: 8 }, method: 'get' }).then((resp) => { // 请求成功
          if (resp.return_code === '0000') {
            this.prd_list = resp.data.list
            this.prd_list = this.prd_list.slice(1)
            this.special_push_prd = resp.data.list[0]
          }
          resolve(resp)
        }).catch((error) => { // 请求失败
          this.$_requestInterceptor('error', error)
          reject(error)
        })
      })
    },
    showTips (e, prdInfo) {
      this.first_show = true
      this.active_prd = prdInfo
      this.parent_info = e.data
    },
    againOpenTips () {
      this.first_show = false
      this.last_show = true
    },
    closeTips () {
      this.first_show = false
      this.last_show = false
    },
    goMorePrd () {
      let isMini = sessionStorage.getItem('isMini')
      if (isMini) {
        let url = encodeURIComponent(this.$Tool.imgPath('/merber/prd_index'))
        window.wx.miniProgram.navigateTo({ url: '/pages/webview/webview?url=' + url })
      } else {
        this.$router.push('/merber/prd_index')
      }
    },
    goToPaymentVip () {
      let isMini = sessionStorage.getItem('isMini')
      if (isMini) {
        let token = sessionStorage.getItem('token')
        if (token) {
          window.wx.miniProgram.navigateTo({ url: '/pages/product/super_details/super_details' })
        } else {
          window.wx.miniProgram.navigateTo({ url: '/pages/login/login' })
        }
      } else {
        this.$router.push('/merber/payment_vip')
      }
    },
    continueBuy () {
      let isMini = sessionStorage.getItem('isMini')
      let params = '?pid=' + this.special_push_prd.id + '&item_id=' + this.special_push_prd.default_item_id
      if (isMini) {
        window.wx.miniProgram.navigateTo({ url: '/pages/shopDetails/shopDetails' + params })
      } else {
        this.$router.push('/main/shopDetails' + params)
      }
    },
    continueBuyList (item) {
      let isMini = sessionStorage.getItem('isMini')
      let params = '?pid=' + item.id + '&item_id=' + item.default_item_id
      if (isMini) {
        window.wx.miniProgram.navigateTo({ url: '/pages/shopDetails/shopDetails' + params })
      } else {
        this.$router.push('/main/shopDetails' + params)
      }
    },
    goToEquity (i) {
      let isMini = sessionStorage.getItem('isMini')
      if (isMini) {
        let url = encodeURIComponent(this.$Tool.imgPath('/active/equity?id=' + i))
        window.wx.miniProgram.navigateTo({ url: '/pages/webview/webview?url=' + url })
      } else {
        this.$router.push('/active/equity?id=' + i)
      }
    },
    goToRights () {
      this.$router.push('/merber/prd_index')
    },
    goToOpenVip () {
      let isMini = sessionStorage.getItem('isMini')
      if (isMini) {
        let token = sessionStorage.getItem('token')
        if (token) {
          window.wx.miniProgram.navigateTo({ url: '/pages/product/super_details/super_details' })
        } else {
          window.wx.miniProgram.navigateTo({ url: '/pages/login/login' })
        }
      } else {
        this.$router.push('/merber/payment_vip')
      }
      // this.$router.push('/merber/payment_vip')
    }
  }
}
</script>
